/*
 * @Author      : ZhouQiJun
 * @Date        : 2025-11-06 12:50:08
 * @LastEditors : ZhouQiJun
 * @LastEditTime: 2025-11-07 15:20:16
 * @Description :
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import federation from '@originjs/vite-plugin-federation'
import topLevelAwait from 'vite-plugin-top-level-await'
import AutoImport from 'unplugin-auto-import/vite'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'pinia']
    }),
    federation({
      name: 'host-app',
      remotes: {
        'remote-app': 'http://localhost:5002/assets/remoteEntry.js'
      },
      shared: {
        vue: {
          singleton: true
          // requiredVersion: '^3.5.0'
        },
        pinia: {
          singleton: true
        }
      }
    })
    //topLevelAwait({
    //  // The export name of top-level await promise for each chunk module
    //  promiseExportName: '__tla',
    //  // The function to generate import names of top-level await promise in each chunk module
    //  promiseImportName: i => `__tla_${i}`,
    //}),
  ],
  build: {
    target: ['chrome89', 'edge89', 'firefox89', 'safari15']
  },
  server: {
    port: 5000
  }
})
